<?php

	session_start();
	$which=$_POST['which'];
include('system/db/conn.php');

	if($which==0){


     $shoporderid=$_POST['shoporderid'];
    
$sql = "update do_deal_order set order_status=3  where id=".$shoporderid;

if(mysql_query($sql,$conn)){

$check_query = mysql_query("select user_id,backYesNo,total_price from do_deal_order where id=".$shoporderid);
if($result = mysql_fetch_array($check_query)){
	
$check_query2 = mysql_query("select point from do_user where id=".$result['user_id']);

if($result2 = mysql_fetch_array($check_query2)){

if($result['backYesNo']!="1"){

$userpoint=	$result2['point']+$result['total_price'];
$levelid=1;
if($userpoint>=200){
$levelid=2;

}if ($userpoint>=300) {
$levelid=3;
}if ($userpoint>=500) {
$levelid=4;
}if ($userpoint>=800) {
	$levelid=5;
}if ($userpoint>=1300) {
	$levelid=6;
}if ($userpoint>=2100) {
	$levelid=7;
}if ($userpoint>=3400) {
	$levelid=8;
}if ($userpoint>=5500) {
	$levelid=9;
}if ($userpoint>=8900) {
	$levelid=10;
}
$sql4 = "update do_user set level_id=".$levelid.",point=".$userpoint."  where id=".$result['user_id'];

if(mysql_query($sql4,$conn)){
	
}



}



}



}

	print_r("yes");
}else{
	print_r("no");
}


}elseif ($which==1) {

     $shoporderid=$_POST['shoporderid'];
   
$sql = "update do_deal_order set order_status=2,backYesNo='1'  where id=".$shoporderid;

if(mysql_query($sql,$conn)){
	print_r("yes");
}else{
print_r("no");

}
}

?>